<?php 
if(!defined('ADMIN')){
	exit('Access Denied');
}
?>
<style>
*{padding:0px; margin:0px; font-size:12px;}
li{list-style-type:none;}
#daBtn{width:600px;}
#daBtn input{cursor:pointer;}
#daBtn #shangyue{float:left;}
#daBtn #xiayue{float:right;}
#da{border:1px solid #999; border-right:none; width:630px; overflow:hidden; border-top:none; border-bottom:none; clear:both;}
.xingqi{ width:640px; overflow:hidden; }
.xingqi li{border-bottom:1px solid #999;float:left;width:80px; overflow:hidden; border-right:1px solid #999; border-top:1px solid #999; text-align:center; background:#8AC5FF; font-weight:bold; padding:5px 0px;}
#da2 .day{width:80px;height:50px;float:left; border-bottom:1px solid #999; border-right:1px solid #999;}
#da2 .dayin{width:100%;height:100%; text-align:center; line-height:50px;}
#button-div{display:none;}
.cls{clear:both;}

</style>
<script type="text/javascript">
$(function(){
	//隐藏月份
	var hiddenday = new Date();    
	var d,x,temp = "";
	
	var d = new Date();
	//变更日期需存入隐藏变量中，在上下月调整中使用
	window.hiddenday = d;    
	initday(d);
	
	function initday(day){
		var d1 = new Date(day.getFullYear(),day.getMonth(),1);
		var d2 = new Date(day.getFullYear(),day.getMonth()+1,0);
		var firstday = new Date(day.getFullYear(),day.getMonth(),1).getDay();
		//当前年
		var year = d2.getFullYear();   
		  
		//当前月份  
		var month = parseInt(d2.getMonth())+1;    
			month = month < 10 ? '0' + month:month;
			
		//日期从1计数	
		var countDay = 1;   
		
		//整月有多少天             
		var dayofmonth = d2.getDate();    
		
		temp="";
		for(i=0;i<firstday;i++){
			temp+="<div class=\"day\"><div class=\"dayin\"></div></div>"
		};
	
		var arr = new Array();
		//将日期载入arr
		for(;countDay <= dayofmonth;countDay++){
			arr.push(year + "-" + month + "-" + (countDay<10 ? '0' + countDay : countDay));
		};  
		//拼接显示  
		for(a in arr){
			temp += "<div class=\"day\" id=\"a"+ arr[a] +"\"><div class=\"dayin\">"+ arr[a] +"</div></div>"
		};   
		//将数据放入div中 
		$("#da2").html(temp);
		temp = null;
		
		//给每个日期绑定click事件
		var dayClick = $(".day");
		for(var i=0; i<dayClick.length; i++){
			var oClick = dayClick[i];
			$(oClick).click(function(){
				var oID = $(this).attr("id");
				//获取该日期是否排档
				if(oID && $(this).attr("ok")){
					//已排档
				    //	alert('已排档');
					var da = $(this).attr("id").substring(1);
                    //var odSelect = $("#delData");
                    var odDay = $(this).contents().html();
                    $("#dangqi").html(odDay);
                    $("#orderDate").val(odDay);
                    $.pdialog.closeCurrent();
                                        
				}else{

					
				};
                setdate();
			});
		};
		
		//已排档的日期
		var okData = $("#okData option");
		for(var i=0; i<okData.length; i++){
			var aDay = okData[i].innerHTML;
			var redDay = "a" + aDay;
			$("#" + redDay).css("background","#cccccc");
			$("#" + redDay).attr('ok','ok');
		};
		
	}
	
	//下个月
	$("#shangyue").click(function(){
		hiddenday = new Date(hiddenday.getFullYear(),hiddenday.getMonth()-1,1);
		initday(hiddenday);
	});
	//上个月
	$("#xiayue").click(function(){
		hiddenday = new Date(hiddenday.getFullYear(),hiddenday.getMonth()+1,1);
		initday(hiddenday);
	});
	function setdate(){
		var okData2 = $("#addData option");
        var s2="";
		for(var i=0; i<okData2.length; i++){
		  
          s2=s2+","+okData2[i].innerHTML;
        }
        $("#addDatalist").val(s2);
		var s3="";
        var okData3 = $("#delData option");
		for(var i=0; i<okData3.length; i++){
		  s3=s3+","+okData3[i].innerHTML;
        }        
        $("#delDatalist").val(s3);
	}
});
</script>
<select style="display:none;" id="okData" name="">
<?
while(list($k,$v)=each($datrow)){
?>
<option><?=$v["sdate"]?></option>
<?
}
?>
</select>
<div class="pageContent">
<form action="index.php?mod=<?=MOD?>&act=<?=ACT?>&" method="post"  class="pageForm required-validate"  name="form1" onsubmit="return validateCallback(this, dialogAjaxDone);">
<input type="hidden" name="id" value="<?=$row['id']?>" />
<input type="hidden" name="sub" value="save" />

<input type="hidden" name="addDatalist" id="addDatalist" value="" />
<input type="hidden" name="delDatalist" id="delDatalist" value="" />

<div class="pageFormContent" layoutH="50">
<p><label>名店/名厨：</label>
<?=$row['name']?>
</p>
<p><label>选择排期：</label>
<input type="button" style="height: 20px;" id="shangyue" value="<<上 月 " /> &nbsp;&nbsp;&nbsp;&nbsp;  <input type="button"  style="height: 20px;" id="xiayue"  value=" 下 月>> " />
</p>
<div id="da">
<div class="xingqi">
<ul style="width: 640px;">
			<li style="width: 80px;">星期日</li>
			<li style="width: 80px;">星期一</li>
			<li style="width: 80px;">星期二</li>
			<li style="width: 80px;">星期三</li>
			<li style="width: 80px;">星期四</li>
			<li style="width: 80px;">星期五</li>
			<li style="width: 80px;">星期六</li>
			</ul>
		</div>
		
		<div class="cls"></div>
		
		<!--详细日期-->
		<div id="da2"></div>
		<!--详细日期 END-->
</div>
<select id="addData" name="" style="display:none;"></select>
<select id="delData" name="" style="display:none;"></select>

</div>
<div class="formBar">

</form>
</div>
